//package com.plian.system.service.yth.impl;
//
//import com.baomidou.dynamic.datasource.annotation.DS;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.plian.Tools.CollectionUtil;
//import com.plian.system.entity.yth.dj.PartyBaseInformation;
//import com.plian.system.mapper.yth.dj.PartyBaseInformationMapper;
//import com.plian.system.service.yth.IPartyBaseInformationService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Propagation;
//import org.springframework.transaction.annotation.Transactional;
//import java.time.ZoneId;
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//import java.util.Optional;
//
///**
// * @Description:
// * @Author: jatpen
// * @Date: 2023/4/20 9:13 AM
// */
//@Slf4j
//@Service
//@DS("slave_1")
//public class PartyBaseInformationServiceImpl extends ServiceImpl<PartyBaseInformationMapper, PartyBaseInformation> implements IPartyBaseInformationService {
//
//    private final String YTH_DATASOURCE_TYPE = "3";
//
//    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
//    @DS("slave_1")
//    @Override
//    public List<DjPartymemberBaseInfo> getSyncData(Date startTime, Date endTime) {
//        List<DjPartymemberBaseInfo> djPartymemberBaseInfos = new ArrayList<>();
//        List<PartyBaseInformation> partyBaseInformations = list(new LambdaQueryWrapper<PartyBaseInformation>()
//                .gt(Optional.ofNullable(startTime).isPresent(), PartyBaseInformation::getCreateTime, startTime)
//                .le(Optional.ofNullable(endTime).isPresent(), PartyBaseInformation::getCreateTime, endTime)
//        );
//        if (CollectionUtil.isNotEmpty(partyBaseInformations)) {
//            djPartymemberBaseInfos = conversion(partyBaseInformations);
//        }
//        return djPartymemberBaseInfos;
//    }
//
//    /**
//     * 转换对象
//     *
//     * @param partyBaseInformations
//     * @return
//     */
//    private List<DjPartymemberBaseInfo> conversion(List<PartyBaseInformation> partyBaseInformations) {
//
//        List<DjPartymemberBaseInfo> djPartymemberBaseInfos = new ArrayList<>();
//        for (PartyBaseInformation partyBaseInformation : partyBaseInformations) {
//            DjPartymemberBaseInfo djPartymemberBaseInfo = new DjPartymemberBaseInfo();
//            djPartymemberBaseInfo.setFillingUnitId(partyBaseInformation.getReportOrgId().toString());
//            djPartymemberBaseInfo.setFillingUnitName(partyBaseInformation.getReportOrgName());
//            djPartymemberBaseInfo.setFillingCreateUserName(partyBaseInformation.getReportUserName());
//            djPartymemberBaseInfo.setFillingCreateUserCode(partyBaseInformation.getReportUserId().toString());
//            djPartymemberBaseInfo.setFillingTime(Date.from(partyBaseInformation.getReportTime().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()));
//            djPartymemberBaseInfo.setPeopleNum(Math.toIntExact(partyBaseInformation.getPartyMembers()));
//            djPartymemberBaseInfo.setGtAge50Num(Math.toIntExact(partyBaseInformation.getAgeValue1()));
//            djPartymemberBaseInfo.setAge3050Num(Math.toIntExact(partyBaseInformation.getAgeValue2()));
//            djPartymemberBaseInfo.setAge2535Num(Math.toIntExact(partyBaseInformation.getAgeValue3()));
//            djPartymemberBaseInfo.setLtAge25Num(Math.toIntExact(partyBaseInformation.getAgeValue4()));
//            djPartymemberBaseInfo.setLtJuniorCollegeNum(Math.toIntExact(partyBaseInformation.getEducationValue1()));
//            djPartymemberBaseInfo.setJuniorCollegeNum(Math.toIntExact(partyBaseInformation.getEducationValue2()));
//            djPartymemberBaseInfo.setUndergraduateNum(Math.toIntExact(partyBaseInformation.getEducationValue3()));
//            djPartymemberBaseInfo.setMasterNum(Math.toIntExact(partyBaseInformation.getEducationValue4()));
//            djPartymemberBaseInfo.setDoctorateNum(Math.toIntExact(partyBaseInformation.getEducationValue5()));
//            djPartymemberBaseInfo.setPostdoctorNum(Math.toIntExact(partyBaseInformation.getEducationValue6()));
//            // djPartymemberBaseInfo.setNaturePartymember(); //党员性质
//            djPartymemberBaseInfo.setDataSource(YTH_DATASOURCE_TYPE);
//            djPartymemberBaseInfo.setDataSourceId(partyBaseInformation.getId().toString());
//
//            djPartymemberBaseInfos.add(djPartymemberBaseInfo);
//        }
//        return djPartymemberBaseInfos;
//    }
//}
